<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layui-form layuimini-form layui-form-pane">
    <div class="layui-form-item">
        <input type="hidden" name="code" value="{$info.code}">
        <label class="layui-form-label required">玩家名称</label>
        <div class="layui-input-inline">
            <input type="text" name="info[name]" lay-verify="required" lay-reqtext="玩家名称不能为空" placeholder="请输入玩家名称" value="{$info.name}" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">玩家ID</label>
        <div class="layui-input-inline">
            <input type="text" value="{$info.code}" readonly autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">玩家手机号</label>
        <div class="layui-input-inline">
            <input type="number" name="info[phone]" lay-verify="required|phone" lay-reqtext="手机号不能为空" placeholder="请输入玩家手机号" value="{$info.phone}" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">玩家头像</label>
        <input type="hidden" id="headHidden" name="info[head_portrait]">
        <div class="layui-input-inline uploadHeadImage">
            <div class="layui-upload-drag" id="headImg">
                <i class="layui-icon"></i>
                <p>点击上传图片，或将图片拖拽到此处</p>
            </div>
        </div>
        <div class="" style="display: flex">
            <div class="layui-upload-list" style="margin-top: 5px;">
                <img class="layui-upload-img headImage" style="height: 100px;" src="/upload/{$info.head_portrait}" id="head_portrait">
                <p id="headText"></p>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <!--<span class="x-red">*</span>为保证图片质量，图片大小不要超过500KB,一般在30KB-100KB之间-->
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">注册日期</label>
        <div class="layui-input-inline">
            <input type="text" name="info[register_time]" id="date" lay-verify="datetime|required" placeholder="注册日期" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label required">玩家等级</label>
        <div class="layui-input-inline">
            <input type="hidden" name="info[level]" id="levelHidden" lay-verify="required" value="{$info.level}">
            <input type="text" placeholder="请选择玩家等级" autocomplete="off" readonly class="layui-input" id="level" value="{$info.levelTitle}" ts-selected="{$info.level}">
        </div>
        <label class="layui-form-label required">所属团队</label>
        <div class="layui-input-inline">
            <input type="hidden" name="info[team_id]" id="teamHidden" lay-verify="required" value="{$info.team_id}">
            <input type="text" placeholder="请选择所属团队" autocomplete="off" readonly class="layui-input" id="team" value="{$info.teamTitle}" ts-selected="{$info.team_id}">
        </div>
        <label class="layui-form-label required">身份证号</label>
        <div class="layui-input-inline">
            <input type="text" name="info[idnumber]" lay-verify="required|identity" placeholder="请输入身份证号" autocomplete="off" value="{$info.idnumber}" class="layui-input">
        </div>
        <label class="layui-form-label required">状态</label>
        <div class="layui-input-inline">
            <select name="info[status]">
                <option value="1" {if condition="$info.status==1" }selected{/if}>未注册</option>
                <option value="2" {if condition="$info.status==2" }selected{/if}>已注册</option>
                <option value="3" {if condition="$info.status==3" }selected{/if}>未激活</option>
                <option value="4" {if condition="$info.status==4" }selected{/if}>等待审核</option>
                <option value="4" {if condition="$info.status==5" }selected{/if}>已激活</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">身份证照片</label>
        <input type="hidden" id="idcardHidden" name="info[idcard]">
        <div class="layui-input-inline uploadHeadImage">
            <div class="layui-upload-drag" id="idcardImg">
                <i class="layui-icon"></i>
                <p>点击上传图片，或将图片拖拽到此处</p>
            </div>
        </div>
        <div class="" style="display: flex">
            <div class="layui-upload-list" style="margin-top: 5px;">
                <img class="layui-upload-img headImage" style="height: 100px;" src="/upload/{$info.idcard}" id="idcard">
                <p id="idcardText"></p>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <!--<span class="x-red">*</span>为保证图片质量，图片大小不要超过500KB,一般在30KB-100KB之间-->
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-inline">
            <input type="radio" name="info[sex]" value="1" title="男" {if condition="$info.sex==1" }checked="" {/if}>
            <input type="radio" name="info[sex]" value="2" title="女" {if condition="$info.sex==2" }checked="" {/if}>
        </div>
        <label class="layui-form-label required">年龄</label>
        <div class="layui-input-inline">
            <input type="number" name="info[age]" placeholder="请输入年龄" lay-verify="required" autocomplete="off" value="{$info.age}" class="layui-input">
        </div>
        <label class="layui-form-label required">地区选择</label>
        <div class="" id="area-picker">
            <div class="layui-input-inline" style="width: 163px">
                <select name="info[province]" class="province-selector" lay-filter="province-1">
                    <option value="">请选择省</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 164px">
                <select name="info[city]" class="city-selector" lay-filter="city-1">
                    <option value="">请选择市</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 163px">
                <select name="info[area]" class="county-selector" lay-filter="county-1">
                    <option value="">请选择区</option>
                </select>
            </div>
        </div>
        <label class="layui-form-label required">类型</label>
        <div class="layui-input-inline">
            <select name="info[type]">
                <option value="1" {if condition="$info.type==1" }selected{/if}>账号正常</option>
                <option value="2" {if condition="$info.type==2" }selected{/if}>合伙人</option>
                <option value="3" {if condition="$info.type==3" }selected{/if}>账号封停</option>
                <option value="4" {if condition="$info.type==4" }selected{/if}>玩家退出</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">支付宝</label>
        <div class="layui-input-inline">
            <input type="text" name="collection[ali_number]" placeholder="请输入支付宝账号" autocomplete="off" value="{$info.ali_number}" class="layui-input">
        </div>
        <label class="layui-form-label">微信</label>
        <div class="layui-input-inline">
            <input type="text" name="collection[wx_number]" placeholder="请输入微信号" autocomplete="off" value="{$info.wx_number}" class="layui-input">
        </div>
        <label class="layui-form-label">

            银联</label>
        <div class="layui-input-inline">
            <input type="text" name="collection[unionpay_number]" placeholder="请输入银联账号" autocomplete="off" value="{$info.unionpay_number}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="color: #00a0e9">
        <label class="layui-form-label">收益总额</label>
        <div class="layui-input-inline" >
            <input type="number" name="property[income]" autocomplete="off" value="{$info.income}" class="layui-input">
        </div>
        <label class="layui-form-label">材料数量</label>
        <div class="layui-input-inline" >
            <input type="number" name="property[materials]" autocomplete="off" value="{$info.materials}" class="layui-input">
        </div>
        <label class="layui-form-label">积分数量</label>
        <div class="layui-input-inline" >
            <input type="number" name="property[integral]" autocomplete="off" value="{$info.integral}" class="layui-input">
        </div>
        <label class="layui-form-label">金币数量</label>
        <div class="layui-input-inline" >
            <input type="number" name="property[gold]" autocomplete="off" value="{$info.gold}" class="layui-input">
        </div>
        <label class="layui-form-label">团队人数</label>
        <div class="layui-input-inline" >
            <input type="number" autocomplete="off" value="{$info.team_num}" readonly class="layui-input">
        </div>
        <input type="hidden" name="property_old[income]" value="{$info.income}">
        <input type="hidden" name="property_old[materials]" value="{$info.materials}">
        <input type="hidden" name="property_old[integral]" value="{$info.integral}">
        <input type="hidden" name="property_old[gold]" value="{$info.gold}">
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use(['form', 'laydate', 'tableSelect', 'layarea', 'upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            tableSelect = layui.tableSelect,
            layarea = layui.layarea,
            upload = layui.upload,
            $ = layui.$;
        /*注册日期*/
        laydate.render({
            elem: '#date',
            type: 'datetime',
            value: "{$info.register_time}"
        });
        /*玩家等级*/
        tableSelect.render({
            elem: '#level',
            searchKey: 'title',
            checkedKey: 'level',
            searchPlaceholder: '名称搜索',
            table: {
                url: '/admin/Member/memberLevelInfo?action=ajax',
                method: 'post',
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.data, //解析数据列表
                    };
                },
                cols: [[
                    {type: 'radio'},
                    {field: 'level', title: '等级', sort: true},
                    {field: 'title', title: '名称', sort: true},
                ]],
                page: true,
                limits: [15, 20, 25, 30, 50, 100],
                limit: 15
            },
            done: function (elem, data) {
                var NEWJSON = [];
                var levelHidden = [];
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.title)
                    levelHidden.push(item.level)
                })
                elem.val(NEWJSON.join(","))
                $('#levelHidden').val(levelHidden.join(","))
            }
        });
        /*所属团队*/
        tableSelect.render({
            elem: '#team',
            searchKey: 'title',
            checkedKey: 'id',
            searchPlaceholder: '名称搜索',
            table: {
                url: '/admin/Member/teamInfo?action=ajax',
                method: 'post',
                parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.data, //解析数据列表
                    };
                },
                cols: [[
                    {type: 'radio'},
                    {field: 'title', title: '团队名称', sort: true},
                    {field: 'team_num', title: '团队人数', sort: true},
                    {field: 'income', title: '团队总收益', sort: true},
                ]],
                page: true,
                limits: [10, 15, 20, 25, 30, 50, 100],
                limit: 10
            },
            done: function (elem, data) {
                var NEWJSON = [];
                var teamHidden = [];
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.title)
                    teamHidden.push(item.id)
                })
                elem.val(NEWJSON.join(","))
                $('#teamHidden').val(teamHidden.join(","))
            }
        });
        /*城市级联*/
        layarea.render({
            elem: '#area-picker',
            data: {
                province: "{$info.province}",
                city: "{$info.city}",
                county: "{$info.area}"
            },
            change: function (res) {
            }
        });
        /*玩家头像*/
        var uploadInst = upload.render({
            elem: '#headImg',
            url: '/admin/Industry/Doupload',
            size: 51200000,
            field: 'headImg',
            accept: 'images',
            acceptMime: 'image/*',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#head_portrait').attr('src', result); //图片链接（base64）;
                });
                this.data = {
                    'mark': 'img',
                    'field': 'headImg',
                    'oldSrc': $("#headHidden").val()
                };
            },
            done: function (res) {
                //如果上传失败
                if (res.status == false) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                $("#headHidden").val(res.src);
                var demoText = $('#headText');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            },
            error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#headText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            },
        });
        /*身份证照片*/
        var uploadidcardInst = upload.render({
            elem: '#idcardImg',
            url: '/admin/Industry/Doupload',
            size: 51200000,
            field: 'idcardImg',
            accept: 'images',
            acceptMime: 'image/*',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#idcard').attr('src', result); //图片链接（base64）;
                });
                this.data = {
                    'mark': 'img',
                    'field': 'idcardImg',
                    'oldSrc': $("#idcardHidden").val()
                };
            },
            done: function (res) {
                //如果上传失败
                if (res.status == false) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                $("#idcardHidden").val(res.src);
                var demoText = $('#idcardText');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            },
            error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#idcardText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadidcardInst.upload();
                });
            },
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: '/admin/Member/write?action=ajax',
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (res) {
                    if (res.status == true) {
                        // 关闭弹出层
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });
            return false;
        });
        //监听删除玩家
        form.on('submit(deleteBtn)', function (data) {
            layer.confirm('真的删除玩家么', function (index) {
                $.ajax({
                    url: '/admin/Member/write?action=delete',
                    type: 'post',
                    dataType: 'json',
                    data: {memberCode:"{$info.code}"},
                    success: function (res) {
                        if (res.status == true) {
                            // 关闭弹出层
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            window.parent.location.reload();
                        } else {
                            layer.close(index);
                            layer.msg(res.msg);
                        }
                    },
                    error: function () {
                        layer.msg("报错了");
                    }
                });
            });
            return false;
        });

    });
</script>
<script>
    /*用户各种记录*/
    function checkMemberInfo(code, type, title) {
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.5,
            area: ['80%', '90%'],
            content: '/admin/Member/memberInfo?view=' + type + '&memberCode=' + code
        });
    }
</script>
</body>
</html>